﻿using System;
using System.Collections.Generic;
using System.Text;

namespace He.API.WeiXin
{
    public class NodesHandle
    {
        /// <summary>
        /// 图片路径处理
        /// </summary>
        /// <param name="imgUrl"></param>
        /// <param name="siteDomain"></param>
        /// <returns></returns>
        public static string HandleImgUrl(string imgUrl, string siteDomain)
        {
            if (imgUrl.StartsWith("http://"))
            {
                return imgUrl;
            }
            else
            {
                return string.Format("http://{0}{1}", siteDomain.Trim('/'), imgUrl);
            }
        }

        /// <summary>
        /// 跳转链接处理
        /// </summary>
        /// <param name="wx_keyword"></param>
        /// <param name="aid"></param>
        /// <param name="siteInfo"></param>
        /// <returns></returns>
        public static string HandleLinkUrl(int aid, string siteDomain, string enginePage)
        {
            Model.article article = new BLL.article().GetModel(aid);
            if (!string.IsNullOrEmpty(article.link_url))
            {
                return article.link_url;
            }
            else
            {
                return string.Format("http://{0}{1}?p=show&id={2}", siteDomain, enginePage, aid);
            }
        }
    }
}
